package com.huawei.appgallery.search.ui.card;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView.j;
import com.huawei.appgallery.foundation.card.base.bean.KeywordInfo;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.search.ui.cardbean.HistorySearchCardBean;
import com.huawei.appgallery.search.ui.widget.HorizontalTextRecyclerView;
import java.util.List;
import o.azb;
import o.cgz;
import o.chy;
import o.cih;
import o.cuv.b;
import o.cuv.f;
import o.cvk;
import o.cvm;
import o.ContentManager;
import o.CollectCheck;
import o.MinimumFactory;
import o.evx;

public class HistorySearchCard extends BaseDistCard {
    private TextView ʻ;
    private TextView ʼ;
    private cvm ʽ = null;
    private List<KeywordInfo> ˋ = null;
    private View ॱॱ;
    private OnClickListener ᐝ = new evx(this) {
        final /* synthetic */ HistorySearchCard ˏ;

        {
            this.ˏ = r1;
        }

        public void ˋ(View view) {
            if (this.ˏ.ʼॱ instanceof Activity) {
                cvk.ॱ().ˊ((Activity) this.ˏ.ʼॱ);
                if (!CollectCheck.isEmpty(this.ˏ.ˋ)) {
                    this.ˏ.ˋ.clear();
                }
                if (this.ˏ.ʽ != null) {
                    this.ˏ.ʽ.ˊ(this.ˏ.ˋ);
                }
                this.ˏ.ʼ.setText("");
                this.ˏ.ʻ.setText("");
                this.ˏ.ˎ();
            }
        }
    };

    public HistorySearchCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        this.ॱॱ = view;
        azb.ˏ(view, b.ʾॱ);
        View findViewById = view.findViewById(b.ˏॱ);
        findViewById.setPaddingRelative(azb.ˊ(this.ʼॱ), findViewById.getPaddingTop(), findViewById.getPaddingEnd(), findViewById.getPaddingBottom());
        this.ʼ = (TextView) view.findViewById(b.ॱᐝ);
        this.ʼ.setOnClickListener(this.ᐝ);
        this.ʻ = (TextView) view.findViewById(b.ʾ);
        ॱ(view);
        ʽ(view);
        return this;
    }

    private void ॱ(View view) {
        if (view != null) {
            view.setClickable(true);
            HorizontalTextRecyclerView horizontalTextRecyclerView = (HorizontalTextRecyclerView) view.findViewById(b.ʿ);
            j linearLayoutManager = new LinearLayoutManager(view.getContext(), 0, false);
            horizontalTextRecyclerView.setLayoutManager(linearLayoutManager);
            if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
                horizontalTextRecyclerView.setLayoutDirection(0);
                linearLayoutManager.ˊ(true);
            }
            this.ʽ = new cvm(this.ˋ);
            horizontalTextRecyclerView.setAdapter(this.ʽ);
        }
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (this.ʼॱ instanceof Activity) {
            this.ˋ = cvk.ॱ().ˎ((Activity) this.ʼॱ);
            ((HistorySearchCardBean) cardBean).ˎ(this.ˋ);
            if (CollectCheck.isEmpty(this.ˋ)) {
                this.ʼ.setText("");
                this.ʻ.setText("");
                ˎ();
            } else {
                this.ʼ.setText(f.ˏॱ);
                this.ʻ.setText(f.ˋॱ);
            }
            if (this.ʽ != null) {
                this.ʽ.ˊ(this.ˋ);
            }
        }
    }

    public void ˏ(chy o_chy) {
        if (this.ʽ != null) {
            this.ʽ.ॱ(o_chy, (cih) this);
        }
    }

    private void ˎ() {
        if (this.ॱॱ != null) {
            LayoutParams layoutParams = (LayoutParams) this.ॱॱ.getLayoutParams();
            layoutParams.height = 0;
            this.ॱॱ.setLayoutParams(layoutParams);
        }
    }
}
